home *** CD-ROM | disk | FTP | other *** search
/ Family Forum 262 / SOMC Family Forum 262.iso / Xtras / Animation Wizard.dir / 00014_CastMgr.ls < prev    next >
Encoding:
Text File  |  1997-05-10  |  3.1 KB  |  108 lines

  1. on birth me
  2.   return me
  3. end
  4.  
  5. on mFindFreeCastRun me, howMany, startIndex
  6.   global gDevelopmentFlag
  7.   if gDevelopmentFlag then
  8.     set castNumberToStartLooking to 400
  9.   else
  10.     set castNumberToStartLooking to startIndex
  11.   end if
  12.   repeat while 1
  13.     tell the stage
  14.       set startEmptyRun to findEmpty(member castNumberToStartLooking of castLib 1)
  15.     end tell
  16.     if howMany = 1 then
  17.       return startEmptyRun
  18.     end if
  19.     set OKRunFlag to 1
  20.     repeat with nextCastMember = startEmptyRun + 1 to startEmptyRun + howMany - 1
  21.       if nextCastMember = 32000 then
  22.         alert("There is not enough free space in your cast to create this auto-animation.  Delete any unused castmembers and try again.")
  23.         return 0
  24.       end if
  25.       tell the stage
  26.         set nextEmpty to findEmpty(member nextCastMember of castLib 1)
  27.       end tell
  28.       if nextEmpty <> nextCastMember then
  29.         set castNumberToStartLooking to nextCastMember
  30.         set OKRunFlag to 0
  31.         exit repeat
  32.       end if
  33.     end repeat
  34.     if OKRunFlag then
  35.       return startEmptyRun
  36.     end if
  37.   end repeat
  38. end
  39.  
  40. on mModifyRichTextCM me, theText, theFont, theSize
  41.   set theCastName to "RichText" && theFont && theSize
  42.   set theCastNum to the number of member theCastName
  43.   if theCastNum < 1 then
  44.     alert("Internal error: mModifyRichTextCM could not find" && theCastName)
  45.     return 0
  46.   end if
  47.   set the text of member theCastNum to theText
  48.   return theCastNum
  49. end
  50.  
  51. on mGetTextWidth me, theCastNum
  52.   set theName to the name of member theCastNum
  53.   set theFontNameAndSize to word 2 of theName & word 3 of theName
  54.   set saveText to the text of member theCastNum
  55.   case theFontNameAndSize of
  56.     "Helvetica24":
  57.       set theMWidth to 20
  58.     "Times24":
  59.       set theMWidth to 22
  60.     "Palatino24":
  61.       set theMWidth to 21
  62.     "Courier24":
  63.       set theMWidth to 23
  64.     "HelveticaBold24":
  65.       set theMWidth to 24
  66.     "TimesBold24":
  67.       set theMWidth to 25
  68.     "PalatinoBold24":
  69.       set theMWidth to 14
  70.     "CourierBold24":
  71.       set theMWidth to 15
  72.     "Arial24":
  73.       set theMWidth to 20
  74.     "TimesNewRoman24":
  75.       set theMWidth to 21
  76.     "CourierNew24":
  77.       set theMWidth to 14
  78.     "ArialBold24":
  79.       set theMWidth to 24
  80.     "TimesNewRomanBold24":
  81.       set theMWidth to 23
  82.     "CourierNewBold24":
  83.       set theMWidth to 15
  84.     otherwise:
  85.       alert("Internal error, mGetTextwidth could find find :" & theFontNameAndSize)
  86.   end case
  87.   set originalHeight to the height of member theCastNum
  88.   set extraMs to 0
  89.   repeat while the height of member theCastNum = originalHeight
  90.     set extraMs to extraMs + 1
  91.     set the text of member theCastNum to the text of member theCastNum & "M"
  92.   end repeat
  93.   set extraMs to extraMs - 1
  94.   set fieldWidth to the width of member theCastNum
  95.   set sizeOfExtraMs to extraMs * theMWidth
  96.   set theRealWidth to fieldWidth - sizeOfExtraMs
  97.   set the text of member theCastNum to saveText
  98.   return theRealWidth
  99. end
  100.  
  101. on mGetTextHeight me, theCastNum
  102.   set theRect to the rect of member theCastNum
  103.   set theRectString to string(theRect)
  104.   set theWidthString to item 4 of theRectString
  105.   set theWidth to value(theWidthString)
  106.   return theWidth
  107. end
  108.